/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.crystalrange.documents.service.impl;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;
import java.util.Date;
import java.util.List;
import org.crystalrange.documents.dao.DocumentTagDao;
import org.crystalrange.documents.model.DocumentTag;
import org.crystalrange.documents.service.DocumentTagService;
import org.crystalrange.model.User;
import org.crystalrange.service.UserService;

/**
 *
 * @author Krzysiek
 */
public class DocumentTagServiceImpl implements DocumentTagService {

    private DocumentTagDao documentTagDao;
    private UserService userService;

    public DocumentTagDao getDocumentTagDao() {
        return documentTagDao;
    }

    public void setDocumentTagDao(DocumentTagDao documentTagDao) {
        this.documentTagDao = documentTagDao;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    
    public DocumentTag create(String username) {
        User currentUser = this.userService.findByUsername(username);   
        
        DocumentTag documentTag = new DocumentTag();
        documentTag.setCreatedBy(currentUser);
        documentTag.setCreatedDate(new Date());
        
        return documentTag;
    }

    public boolean save(DocumentTag documentTag) {
        return this.documentTagDao.save(documentTag);
    }

    public boolean remove(DocumentTag documentTag) {
        return this.documentTagDao.remove(documentTag);
    }

    public DocumentTag find(Long id) {
        return this.documentTagDao.find(id);
    }

    public List<DocumentTag> findAll() {
        return this.documentTagDao.findAll();
    }

    public SearchResult<DocumentTag> searchAndCount(Search search) {
        return this.documentTagDao.searchAndCount(search);
    }

    public List<DocumentTag> search(Search search) {
        return this.documentTagDao.search(search);
    }

    public DocumentTag searchUnique(Search search) {
        return this.documentTagDao.searchUnique(search);
    }
    
}
